/*
 * Copyright 2010 J Patrick Davenport
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package v4view.web;

public class OptGroup extends ChildbearingPageElement implements IMouseEvents<OptGroup>, IKeyboardEvents<OptGroup>, ILanguageAttributes<OptGroup>, ICoreAttributes {
	private static final String	DISABLED_VALUE		= "disabled";
	private static final String	OPTION_GROUP_TAG	= "option";
	private static final String	LABEL_KEY			= "label";

	{
		this.setTag(OPTION_GROUP_TAG);
		this.setSupportsAttributes(true);
	}

	public String isDisabled() {
		return this.getAttributeValue(LABEL_KEY);
	}

	public OptGroup setDisabled(final boolean _value) {
		if (_value) {
			this.setAttribute(LABEL_KEY, DISABLED_VALUE);
		} else {
			this.removeAttribute(LABEL_KEY);
		}

		return this;
	}

	public String getLabel() {
		return this.getAttributeValue(LABEL_KEY);
	}

	public OptGroup setLabel(final String _value) {
		return (OptGroup) this.setAttribute(LABEL_KEY, _value);
	}

	@Override
	public String getCssClass() {
		return this.getAttributeValue(CSS_CLASS_KEY);
	}

	@Override
	public String getId() {
		return this.getAttributeValue(ID_KEY);
	}

	@Override
	public String getStyle() {
		return this.getAttributeValue(STYLE_KEY);
	}

	@Override
	public String getTitle() {
		return this.getAttributeValue(TITLE_KEY);
	}

	@Override
	public OptGroup setCssClass(final String _value) {
		return (OptGroup) this.setAttribute(CSS_CLASS_KEY, _value);
	}

	@Override
	public OptGroup setId(final String _value) {
		return (OptGroup) this.setAttribute(ID_KEY, _value);
	}

	@Override
	public OptGroup setStyle(final String _value) {
		return (OptGroup) this.setAttribute(STYLE_KEY, _value);
	}

	@Override
	public OptGroup setTitle(final String _value) {
		return (OptGroup) this.setAttribute(TITLE_KEY, _value);
	}

	@Override
	public OptGroup setOnKeyDown(final String _scriptlet) {
		return (OptGroup) this.setAttribute(KEY_DOWN_EVENT_KEY, _scriptlet);
	}

	@Override
	public OptGroup setOnKeyPress(final String _scriptlet) {
		return (OptGroup) this.setAttribute(KEY_PRESS_EVENT_KEY, _scriptlet);
	}

	@Override
	public OptGroup setOnKeyUp(final String _scriptlet) {
		return (OptGroup) this.setAttribute(KEY_UP_EVENT_KEY, _scriptlet);
	}

	@Override
	public String getOnKeyDown() {
		return this.getAttributeValue(KEY_DOWN_EVENT_KEY);
	}

	@Override
	public String getOnKeyPress() {
		return this.getAttributeValue(KEY_PRESS_EVENT_KEY);
	}

	@Override
	public String getOnKeyUp() {
		return this.getAttributeValue(KEY_UP_EVENT_KEY);
	}

	@Override
	public OptGroup setDir(final String _value) {
		return (OptGroup) this.setAttribute(DIR_KEY, _value);
	}

	@Override
	public OptGroup setLang(final String _lang) {
		return (OptGroup) this.setAttribute(LANG_KEY, _lang);
	}

	@Override
	public OptGroup setXmlLang(final String _xmlLang) {
		return (OptGroup) this.setAttribute(XML_LANG_KEY, _xmlLang);
	}

	@Override
	public String getDir() {
		return this.getAttributeValue(DIR_KEY);
	}

	@Override
	public String getLang() {
		return this.getAttributeValue(LANG_KEY);
	}

	@Override
	public String getXmlLang() {
		return this.getAttributeValue(XML_LANG_KEY);
	}

	@Override
	public OptGroup setOnClick(final String _scriptlet) {
		return (OptGroup) this.setAttribute(ON_MOUSECLICK_EVENT_KEY, _scriptlet);
	}

	@Override
	public OptGroup setOnDblClick(final String _scriptlet) {
		return (OptGroup) this.setAttribute(ON_MOUSEDBLCLICK_EVENT_KEY, _scriptlet);
	}

	@Override
	public OptGroup setOnMouseDown(final String _scriptlet) {
		return (OptGroup) this.setAttribute(ON_MOUSEDOWN_EVENT_KEY, _scriptlet);
	}

	@Override
	public OptGroup setOnMouseMove(final String _scriptlet) {
		return (OptGroup) this.setAttribute(ON_MOUSEMOVE_EVENT_KEY, _scriptlet);
	}

	@Override
	public OptGroup setMouseOut(final String _scriptlet) {
		return (OptGroup) this.setAttribute(ON_MOUSEOUT_EVENT_KEY, _scriptlet);
	}

	@Override
	public OptGroup setMouseOver(final String _scriptlet) {
		return (OptGroup) this.setAttribute(ON_MOUSEOVER_EVENT_KEY, _scriptlet);
	}

	@Override
	public OptGroup setMouseUp(final String _scriptlet) {
		return (OptGroup) this.setAttribute(ON_MOUSEUP_EVENT_KEY, _scriptlet);
	}

	@Override
	public String getOnClick() {
		return this.getAttributeValue(ON_MOUSECLICK_EVENT_KEY);
	}

	@Override
	public String getOnDblClick() {
		return this.getAttributeValue(ON_MOUSEDBLCLICK_EVENT_KEY);
	}

	@Override
	public String getOnMouseDown() {
		return this.getAttributeValue(ON_MOUSEDOWN_EVENT_KEY);
	}

	@Override
	public String getOnMouseMove() {
		return this.getAttributeValue(ON_MOUSEMOVE_EVENT_KEY);
	}

	@Override
	public String getMouseOut() {
		return this.getAttributeValue(ON_MOUSEOUT_EVENT_KEY);
	}

	@Override
	public String getMouseOver() {
		return this.getAttributeValue(ON_MOUSEOVER_EVENT_KEY);
	}

	@Override
	public String getMouseUp() {
		return this.getAttributeValue(ON_MOUSEUP_EVENT_KEY);
	}

	/**
	 * @throws UnsupportedOperationException caller cannot add children to this element.
	 */
	@Override
	public ChildbearingPageElement addPageElement(final PageElement _element) {
		if (_element instanceof Option) {
			super.addPageElement(_element);
		}

		return this;
	}
}
